package poli.tidia.mobile.proxy;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;


public class LoginProxy {

	public Boolean doLogin(String userId, String password)
	{
		try {

            RestClient client = RestClient.getInstance("http://agora.tidia-ae.usp.br/portal/xlogin");
            client.AddParam("eid",	userId);
            client.AddParam("pw",	password);
            client.AddParam("submit",	"Login");
            
            try {
                client.Execute(RestClient.RequestMethod.POST);
            } catch (Exception e) {
                e.printStackTrace();
            }

            String response = client.getResponse();
            Document doc = Jsoup.parse(response);
            if(doc.title().equalsIgnoreCase("Tidia-Ae : My Workspace : Home"))
            {
            	return true;
            }
            else
            {
            	return false;
            }
        }
        catch (Exception ex) {
            return false;
        }
	}
	
}
